package com.zhongkun.datahome.web.rest;

import com.zhongkun.datahome.common.annotation.Log;
import com.zhongkun.datahome.common.core.domain.R;
import com.zhongkun.datahome.common.enums.BusinessType;
import com.zhongkun.datahome.service.domain.Project;
import com.zhongkun.datahome.service.repository.CommonFileRepository;
import com.zhongkun.datahome.service.req.IdsBody;
import com.zhongkun.datahome.service.req.cmd.file.SignFileBatchCmd;
import com.zhongkun.datahome.service.req.cmd.file.SignFileCmd;
import com.zhongkun.datahome.service.req.qry.file.SignFileQry;
import com.zhongkun.datahome.service.req.qry.project.ProjectQry;
import com.zhongkun.datahome.service.res.CommonFileVo;
import com.zhongkun.datahome.service.res.PageVo;
import com.zhongkun.datahome.service.service.ICommonFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: lifengsheng
 * @Date: 2025/4/17 16:49
 * @Desc
 */
@Api("房产签字资料管理")
@RestController
@RequestMapping("/core/signFile")
public class HouseSignFileController {
    @Resource
    private ICommonFileService commonFileService;

    @ApiOperation("资料列表")
    @PreAuthorize("@ss.hasPermi('core:signFile:list')")
    @GetMapping("/list")
    public R<List<CommonFileVo>> list(SignFileQry qry) {
        return R.ok(commonFileService.list(qry));
    }

    @ApiOperation("新增资料")
    @PreAuthorize("@ss.hasPermi('core:signFile:add')")
    @Log(title = "签字资料", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public R<Long> add(@RequestBody SignFileCmd cmd) {
        return R.ok(commonFileService.add(cmd));
    }

    @ApiOperation("批量保存资料")
    @PreAuthorize("@ss.hasPermi('core:signFile:batchSave')")
    @Log(title = "签字资料", businessType = BusinessType.UPDATE)
    @PostMapping("/batchSave")
    public R<Void> batchSave(@RequestBody SignFileBatchCmd cmd) {
        commonFileService.batchSave(cmd);
        return R.ok();
    }

    @ApiOperation("删除资料")
    @PreAuthorize("@ss.hasPermi('core:signFile:remove')")
    @Log(title = "签字资料", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove")
    public R<Void> remove(@RequestBody IdsBody idsBody) {
        commonFileService.delete(idsBody.getIds());
        return R.ok();
    }
}
